{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "view-in-github"
   },
   "source": [
    "<a href=\"https://colab.research.google.com/github/vitaldb/examples/blob/master/vitaldb_tableone.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "KClTefZmMuAk"
   },
   "source": [
    "# How to make a group table\n",
    "In this example, we will make a group table depending on the death status from the <code>vitaldb</code> dataset.\n",
    "\n",
    "> Note that <b>all users who use Vital DB, an open biosignal dataset, must agree to the Data Use Agreement below. \n",
    "</b> If you do not agree, please close this window. \n",
    "Click here: [Data Use Agreement](https://vitaldb.net/dataset/?query=overview&documentId=13qqajnNZzkN7NZ9aXnaQ-47NWy7kx-a6gbrcEsi-gak&sectionId=h.vcpgs1yemdb5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "6eZ6wUWnZU4O",
    "outputId": "672eda3d-468a-48f1-a6d4-fc2c4f033136"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting tableone\n",
      "  Downloading https://files.pythonhosted.org/packages/7f/18/fd82d022652bf744cf6c8ebb6dd9aa13c3530906c5e38be51e28bee3d90c/tableone-0.7.10-py2.py3-none-any.whl\n",
      "Requirement already satisfied: tabulate>=0.8.2 in /usr/local/lib/python3.7/dist-packages (from tableone) (0.8.9)\n",
      "Requirement already satisfied: pandas>=0.22.0 in /usr/local/lib/python3.7/dist-packages (from tableone) (1.1.5)\n",
      "Requirement already satisfied: statsmodels>=0.8.0 in /usr/local/lib/python3.7/dist-packages (from tableone) (0.10.2)\n",
      "Requirement already satisfied: numpy>=1.12.1 in /usr/local/lib/python3.7/dist-packages (from tableone) (1.19.5)\n",
      "Requirement already satisfied: scipy>=0.18.1 in /usr/local/lib/python3.7/dist-packages (from tableone) (1.4.1)\n",
      "Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.7/dist-packages (from pandas>=0.22.0->tableone) (2018.9)\n",
      "Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=0.22.0->tableone) (2.8.1)\n",
      "Requirement already satisfied: patsy>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from statsmodels>=0.8.0->tableone) (0.5.1)\n",
      "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.7.3->pandas>=0.22.0->tableone) (1.15.0)\n",
      "Installing collected packages: tableone\n",
      "Successfully installed tableone-0.7.10\n"
     ]
    }
   ],
   "source": [
    "!pip install tableone"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "V-9Wh1VgQOj3",
    "outputId": "79a1590f-1417-4ab8-ed3a-57fc5f4d5d07"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th colspan=\"5\" halign=\"left\">Grouped by death_inhosp</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>Overall</th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>P-Value</th>\n",
       "      <th>Test</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>n</th>\n",
       "      <th></th>\n",
       "      <td>6388</td>\n",
       "      <td>6331</td>\n",
       "      <td>57</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>caseend, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>2.8 [1.7,4.2]</td>\n",
       "      <td>2.8 [1.7,4.2]</td>\n",
       "      <td>2.7 [1.9,4.5]</td>\n",
       "      <td>0.376</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>anestart, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>-0.1 [-0.3,-0.1]</td>\n",
       "      <td>-0.1 [-0.3,-0.1]</td>\n",
       "      <td>-0.1 [-0.3,-0.1]</td>\n",
       "      <td>0.517</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aneend, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>2.7 [1.7,4.2]</td>\n",
       "      <td>2.7 [1.7,4.2]</td>\n",
       "      <td>2.7 [1.7,4.6]</td>\n",
       "      <td>0.232</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>opstart, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.4 [-0.1,0.7]</td>\n",
       "      <td>0.4 [-0.1,0.7]</td>\n",
       "      <td>0.4 [-0.1,0.7]</td>\n",
       "      <td>0.796</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>opend, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>2.5 [1.5,4.0]</td>\n",
       "      <td>2.5 [1.5,4.0]</td>\n",
       "      <td>2.5 [1.6,4.4]</td>\n",
       "      <td>0.246</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>adm, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>-2.3 [-2.6,-1.5]</td>\n",
       "      <td>-2.3 [-2.6,-1.5]</td>\n",
       "      <td>-2.8 [-16.8,-2.3]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>dis, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>4.6 [2.4,7.5]</td>\n",
       "      <td>4.5 [2.4,7.5]</td>\n",
       "      <td>13.5 [5.0,30.4]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>devices, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>5.0 [4.0,5.0]</td>\n",
       "      <td>5.0 [4.0,5.0]</td>\n",
       "      <td>5.0 [4.0,5.0]</td>\n",
       "      <td>0.307</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tracks, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>78.0 [73.0,83.0]</td>\n",
       "      <td>78.0 [74.0,83.0]</td>\n",
       "      <td>78.0 [72.0,83.0]</td>\n",
       "      <td>0.505</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>casedur, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,0.1]</td>\n",
       "      <td>0.0 [0.0,0.1]</td>\n",
       "      <td>0.0 [0.0,0.1]</td>\n",
       "      <td>0.450</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>age, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>59.0 [48.0,68.0]</td>\n",
       "      <td>59.0 [48.0,68.0]</td>\n",
       "      <td>61.0 [47.0,73.0]</td>\n",
       "      <td>0.452</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">sex, n (%)</th>\n",
       "      <th>F</th>\n",
       "      <td>3145 (49.2)</td>\n",
       "      <td>3125 (49.4)</td>\n",
       "      <td>20 (35.1)</td>\n",
       "      <td>0.044</td>\n",
       "      <td>Chi-squared</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>M</th>\n",
       "      <td>3243 (50.8)</td>\n",
       "      <td>3206 (50.6)</td>\n",
       "      <td>37 (64.9)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>height, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>162.2 [156.1,168.7]</td>\n",
       "      <td>162.1 [156.1,168.7]</td>\n",
       "      <td>165.4 [158.2,171.0]</td>\n",
       "      <td>0.392</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>weight, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>60.5 [53.3,68.7]</td>\n",
       "      <td>60.5 [53.4,68.7]</td>\n",
       "      <td>60.3 [51.3,71.2]</td>\n",
       "      <td>0.791</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>bmi, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>23.1 [20.9,25.4]</td>\n",
       "      <td>23.1 [20.9,25.4]</td>\n",
       "      <td>22.7 [20.7,25.3]</td>\n",
       "      <td>0.737</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">asa, n (%)</th>\n",
       "      <th>1.0</th>\n",
       "      <td>1792 (28.6)</td>\n",
       "      <td>1783 (28.8)</td>\n",
       "      <td>9 (16.4)</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Chi-squared (warning: expected count &lt; 5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2.0</th>\n",
       "      <td>3699 (59.1)</td>\n",
       "      <td>3682 (59.4)</td>\n",
       "      <td>17 (30.9)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3.0</th>\n",
       "      <td>703 (11.2)</td>\n",
       "      <td>686 (11.1)</td>\n",
       "      <td>17 (30.9)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4.0</th>\n",
       "      <td>48 (0.8)</td>\n",
       "      <td>36 (0.6)</td>\n",
       "      <td>12 (21.8)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6.0</th>\n",
       "      <td>13 (0.2)</td>\n",
       "      <td>13 (0.2)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">emop, n (%)</th>\n",
       "      <th>0</th>\n",
       "      <td>5606 (87.8)</td>\n",
       "      <td>5578 (88.1)</td>\n",
       "      <td>28 (49.1)</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Chi-squared</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>782 (12.2)</td>\n",
       "      <td>753 (11.9)</td>\n",
       "      <td>29 (50.9)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"4\" valign=\"top\">department, n (%)</th>\n",
       "      <th>General surgery</th>\n",
       "      <td>4930 (77.2)</td>\n",
       "      <td>4886 (77.2)</td>\n",
       "      <td>44 (77.2)</td>\n",
       "      <td>1.000</td>\n",
       "      <td>Chi-squared (warning: expected count &lt; 5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Gynecology</th>\n",
       "      <td>230 (3.6)</td>\n",
       "      <td>228 (3.6)</td>\n",
       "      <td>2 (3.5)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Thoracic surgery</th>\n",
       "      <td>1111 (17.4)</td>\n",
       "      <td>1101 (17.4)</td>\n",
       "      <td>10 (17.5)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Urology</th>\n",
       "      <td>117 (1.8)</td>\n",
       "      <td>116 (1.8)</td>\n",
       "      <td>1 (1.8)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"11\" valign=\"top\">optype, n (%)</th>\n",
       "      <th>Biliary/Pancreas</th>\n",
       "      <td>812 (12.7)</td>\n",
       "      <td>809 (12.8)</td>\n",
       "      <td>3 (5.3)</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Chi-squared (warning: expected count &lt; 5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Breast</th>\n",
       "      <td>434 (6.8)</td>\n",
       "      <td>432 (6.8)</td>\n",
       "      <td>2 (3.5)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Colorectal</th>\n",
       "      <td>1350 (21.1)</td>\n",
       "      <td>1341 (21.2)</td>\n",
       "      <td>9 (15.8)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Hepatic</th>\n",
       "      <td>258 (4.0)</td>\n",
       "      <td>256 (4.0)</td>\n",
       "      <td>2 (3.5)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Major resection</th>\n",
       "      <td>584 (9.1)</td>\n",
       "      <td>578 (9.1)</td>\n",
       "      <td>6 (10.5)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Minor resection</th>\n",
       "      <td>553 (8.7)</td>\n",
       "      <td>553 (8.7)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Others</th>\n",
       "      <td>799 (12.5)</td>\n",
       "      <td>775 (12.2)</td>\n",
       "      <td>24 (42.1)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Stomach</th>\n",
       "      <td>676 (10.6)</td>\n",
       "      <td>672 (10.6)</td>\n",
       "      <td>4 (7.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Thyroid</th>\n",
       "      <td>257 (4.0)</td>\n",
       "      <td>257 (4.1)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Transplantation</th>\n",
       "      <td>403 (6.3)</td>\n",
       "      <td>399 (6.3)</td>\n",
       "      <td>4 (7.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Vascular</th>\n",
       "      <td>262 (4.1)</td>\n",
       "      <td>259 (4.1)</td>\n",
       "      <td>3 (5.3)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">approach, n (%)</th>\n",
       "      <th>Open</th>\n",
       "      <td>3365 (52.7)</td>\n",
       "      <td>3325 (52.5)</td>\n",
       "      <td>40 (70.2)</td>\n",
       "      <td>0.018</td>\n",
       "      <td>Chi-squared (warning: expected count &lt; 5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Robotic</th>\n",
       "      <td>269 (4.2)</td>\n",
       "      <td>266 (4.2)</td>\n",
       "      <td>3 (5.3)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Videoscopic</th>\n",
       "      <td>2754 (43.1)</td>\n",
       "      <td>2740 (43.3)</td>\n",
       "      <td>14 (24.6)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"10\" valign=\"top\">position, n (%)</th>\n",
       "      <th>Left kidney</th>\n",
       "      <td>4 (0.1)</td>\n",
       "      <td>4 (0.1)</td>\n",
       "      <td></td>\n",
       "      <td>0.594</td>\n",
       "      <td>Chi-squared (warning: expected count &lt; 5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Left lateral decubitus</th>\n",
       "      <td>556 (9.0)</td>\n",
       "      <td>554 (9.0)</td>\n",
       "      <td>2 (3.6)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Lithotomy</th>\n",
       "      <td>994 (16.0)</td>\n",
       "      <td>989 (16.1)</td>\n",
       "      <td>5 (8.9)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Prone</th>\n",
       "      <td>148 (2.4)</td>\n",
       "      <td>148 (2.4)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Reverse Trendelenburg</th>\n",
       "      <td>74 (1.2)</td>\n",
       "      <td>73 (1.2)</td>\n",
       "      <td>1 (1.8)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Right kidney</th>\n",
       "      <td>2 (0.0)</td>\n",
       "      <td>2 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Right lateral decubitus</th>\n",
       "      <td>493 (8.0)</td>\n",
       "      <td>488 (8.0)</td>\n",
       "      <td>5 (8.9)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Sitting</th>\n",
       "      <td>5 (0.1)</td>\n",
       "      <td>5 (0.1)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supine</th>\n",
       "      <td>3883 (62.7)</td>\n",
       "      <td>3840 (62.6)</td>\n",
       "      <td>43 (76.8)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Trendelenburg</th>\n",
       "      <td>35 (0.6)</td>\n",
       "      <td>35 (0.6)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">ane_type, n (%)</th>\n",
       "      <th>General</th>\n",
       "      <td>6043 (94.6)</td>\n",
       "      <td>5987 (94.6)</td>\n",
       "      <td>56 (98.2)</td>\n",
       "      <td>0.453</td>\n",
       "      <td>Chi-squared (warning: expected count &lt; 5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Sedationalgesia</th>\n",
       "      <td>72 (1.1)</td>\n",
       "      <td>72 (1.1)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Spinal</th>\n",
       "      <td>273 (4.3)</td>\n",
       "      <td>272 (4.3)</td>\n",
       "      <td>1 (1.8)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>opdur, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,0.1]</td>\n",
       "      <td>0.0 [0.0,0.1]</td>\n",
       "      <td>0.0 [0.0,0.1]</td>\n",
       "      <td>0.417</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>anedur, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,0.1]</td>\n",
       "      <td>0.0 [0.0,0.1]</td>\n",
       "      <td>0.0 [0.0,0.1]</td>\n",
       "      <td>0.336</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>los_postop, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>5.0 [3.0,8.0]</td>\n",
       "      <td>5.0 [3.0,8.0]</td>\n",
       "      <td>14.0 [6.0,32.0]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>los_icu, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>1.0 [0.0,16.0]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">death_inhosp, n (%)</th>\n",
       "      <th>0</th>\n",
       "      <td>6331 (99.1)</td>\n",
       "      <td>6331 (100.0)</td>\n",
       "      <td></td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Fisher's exact</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>57 (0.9)</td>\n",
       "      <td></td>\n",
       "      <td>57 (100.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">preop_htn, n (%)</th>\n",
       "      <th>0</th>\n",
       "      <td>4423 (69.2)</td>\n",
       "      <td>4385 (69.3)</td>\n",
       "      <td>38 (66.7)</td>\n",
       "      <td>0.781</td>\n",
       "      <td>Chi-squared</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1965 (30.8)</td>\n",
       "      <td>1946 (30.7)</td>\n",
       "      <td>19 (33.3)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">preop_dm, n (%)</th>\n",
       "      <th>0</th>\n",
       "      <td>5727 (89.7)</td>\n",
       "      <td>5673 (89.6)</td>\n",
       "      <td>54 (94.7)</td>\n",
       "      <td>0.295</td>\n",
       "      <td>Chi-squared</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>661 (10.3)</td>\n",
       "      <td>658 (10.4)</td>\n",
       "      <td>3 (5.3)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"27\" valign=\"top\">preop_ecg, n (%)</th>\n",
       "      <th>1st degree A-V block</th>\n",
       "      <td>12 (0.2)</td>\n",
       "      <td>11 (0.2)</td>\n",
       "      <td>1 (1.8)</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Chi-squared (warning: expected count &lt; 5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1st degree A-V block with Premature atrial complexes</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1st degree A-V block with Premature supraventricular complexes, Left bundle branch block</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1st degree A-V block, Left bundle branch block</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>AV sequential or dual chamber electronic pacemaker</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Atrial fibrillation</th>\n",
       "      <td>8 (0.1)</td>\n",
       "      <td>7 (0.1)</td>\n",
       "      <td>1 (1.8)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Atrial fibrillation with premature ventricular or aberrantly conducted complexes</th>\n",
       "      <td>2 (0.0)</td>\n",
       "      <td>2 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Atrial fibrillation with premature ventricular, Incomplete left bundle block</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Atrial fibrillation with rapid ventricular response</th>\n",
       "      <td>2 (0.0)</td>\n",
       "      <td>2 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Atrial fibrillation with slow ventricular response</th>\n",
       "      <td>2 (0.0)</td>\n",
       "      <td>2 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Atrial fibrillation, Right bundle branch block</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Atrial flutter with 2:1 A-V conduction</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Atrial flutter with variable A-V block</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Complete right bundle branch block, occasional premature supraventricular complexes</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td>1 (1.8)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Electronic ventricular pacemaker</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Incomplete right bundle branch block</th>\n",
       "      <td>9 (0.1)</td>\n",
       "      <td>8 (0.1)</td>\n",
       "      <td>1 (1.8)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Incomplete right bundle branch block, Left anterior fascicular block</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Left anterior fascicular block</th>\n",
       "      <td>3 (0.0)</td>\n",
       "      <td>3 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Left anterior hemiblock</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Left posterior fascicular block</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Normal Sinus Rhythm</th>\n",
       "      <td>6306 (98.7)</td>\n",
       "      <td>6258 (98.8)</td>\n",
       "      <td>48 (84.2)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Premature atrial complexes</th>\n",
       "      <td>7 (0.1)</td>\n",
       "      <td>6 (0.1)</td>\n",
       "      <td>1 (1.8)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Premature supraventricular and ventricular complexes, Right bundle branch block</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Premature supraventricular complexes</th>\n",
       "      <td>2 (0.0)</td>\n",
       "      <td>2 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Premature ventricular complexes</th>\n",
       "      <td>10 (0.2)</td>\n",
       "      <td>9 (0.1)</td>\n",
       "      <td>1 (1.8)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Right bundle branch block</th>\n",
       "      <td>10 (0.2)</td>\n",
       "      <td>7 (0.1)</td>\n",
       "      <td>3 (5.3)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Right bundle branch block, Left anterior fascicular block</th>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td>1 (0.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"9\" valign=\"top\">preop_pft, n (%)</th>\n",
       "      <th>Borderline obstructive</th>\n",
       "      <td>8 (0.1)</td>\n",
       "      <td>8 (0.1)</td>\n",
       "      <td></td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Chi-squared (warning: expected count &lt; 5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mild obstructive</th>\n",
       "      <td>488 (7.6)</td>\n",
       "      <td>484 (7.6)</td>\n",
       "      <td>4 (7.0)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mild restrictive</th>\n",
       "      <td>261 (4.1)</td>\n",
       "      <td>255 (4.0)</td>\n",
       "      <td>6 (10.5)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mixed or pure obstructive</th>\n",
       "      <td>100 (1.6)</td>\n",
       "      <td>100 (1.6)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Moderate obstructive</th>\n",
       "      <td>114 (1.8)</td>\n",
       "      <td>114 (1.8)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Moderate restrictive</th>\n",
       "      <td>29 (0.5)</td>\n",
       "      <td>29 (0.5)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Normal</th>\n",
       "      <td>5348 (83.7)</td>\n",
       "      <td>5304 (83.8)</td>\n",
       "      <td>44 (77.2)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Severe obstructive</th>\n",
       "      <td>4 (0.1)</td>\n",
       "      <td>4 (0.1)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Severe restrictive</th>\n",
       "      <td>36 (0.6)</td>\n",
       "      <td>33 (0.5)</td>\n",
       "      <td>3 (5.3)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_hb, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>13.0 [11.6,14.2]</td>\n",
       "      <td>13.0 [11.6,14.2]</td>\n",
       "      <td>11.2 [9.1,13.0]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_plt, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>235.0 [191.0,283.0]</td>\n",
       "      <td>235.0 [191.0,283.0]</td>\n",
       "      <td>198.0 [105.0,270.0]</td>\n",
       "      <td>0.004</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_pt, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>101.0 [94.0,109.0]</td>\n",
       "      <td>101.0 [94.0,110.0]</td>\n",
       "      <td>86.0 [53.0,100.0]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_aptt, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>32.1 [30.1,34.4]</td>\n",
       "      <td>32.1 [30.0,34.4]</td>\n",
       "      <td>34.1 [30.9,53.0]</td>\n",
       "      <td>0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_na, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>140.0 [139.0,142.0]</td>\n",
       "      <td>140.0 [139.0,142.0]</td>\n",
       "      <td>138.0 [134.0,140.0]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_k, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>4.2 [3.9,4.4]</td>\n",
       "      <td>4.2 [3.9,4.4]</td>\n",
       "      <td>3.9 [3.8,4.2]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_gluc, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>103.0 [94.0,122.0]</td>\n",
       "      <td>103.0 [94.0,122.0]</td>\n",
       "      <td>111.0 [95.0,136.0]</td>\n",
       "      <td>0.150</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_alb, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>4.2 [3.8,4.4]</td>\n",
       "      <td>4.2 [3.8,4.4]</td>\n",
       "      <td>3.0 [2.7,4.1]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_ast, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>20.0 [17.0,26.0]</td>\n",
       "      <td>20.0 [17.0,26.0]</td>\n",
       "      <td>27.0 [19.0,83.5]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_alt, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>18.0 [13.0,27.0]</td>\n",
       "      <td>18.0 [13.0,27.0]</td>\n",
       "      <td>26.5 [16.2,94.0]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_bun, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>14.0 [11.0,17.0]</td>\n",
       "      <td>14.0 [11.0,17.0]</td>\n",
       "      <td>15.0 [12.0,19.0]</td>\n",
       "      <td>0.111</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_cr, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.8 [0.7,0.9]</td>\n",
       "      <td>0.8 [0.7,0.9]</td>\n",
       "      <td>0.7 [0.5,1.0]</td>\n",
       "      <td>0.073</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_ph, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>7.4 [7.4,7.4]</td>\n",
       "      <td>7.4 [7.4,7.4]</td>\n",
       "      <td>7.4 [7.4,7.5]</td>\n",
       "      <td>0.170</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_hco3, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>24.3 [22.7,26.0]</td>\n",
       "      <td>24.3 [22.7,26.0]</td>\n",
       "      <td>24.0 [23.2,24.9]</td>\n",
       "      <td>0.773</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_be, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>-0.1 [-1.9,1.7]</td>\n",
       "      <td>-0.1 [-1.9,1.7]</td>\n",
       "      <td>-0.1 [-1.5,1.2]</td>\n",
       "      <td>0.958</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_pao2, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>96.0 [78.2,120.8]</td>\n",
       "      <td>96.0 [78.2,120.8]</td>\n",
       "      <td>95.9 [73.1,114.7]</td>\n",
       "      <td>0.854</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_paco2, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>39.5 [36.0,43.7]</td>\n",
       "      <td>39.5 [36.0,43.8]</td>\n",
       "      <td>36.5 [35.4,37.8]</td>\n",
       "      <td>0.189</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>preop_sao2, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>97.0 [94.8,98.2]</td>\n",
       "      <td>97.0 [94.8,98.1]</td>\n",
       "      <td>97.6 [92.6,98.6]</td>\n",
       "      <td>0.620</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">cormack, n (%)</th>\n",
       "      <th>I</th>\n",
       "      <td>5178 (93.2)</td>\n",
       "      <td>5140 (93.3)</td>\n",
       "      <td>38 (92.7)</td>\n",
       "      <td>0.563</td>\n",
       "      <td>Chi-squared (warning: expected count &lt; 5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>II</th>\n",
       "      <td>235 (4.2)</td>\n",
       "      <td>233 (4.2)</td>\n",
       "      <td>2 (4.9)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>IIIa</th>\n",
       "      <td>91 (1.6)</td>\n",
       "      <td>91 (1.7)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>IIIb</th>\n",
       "      <td>35 (0.6)</td>\n",
       "      <td>34 (0.6)</td>\n",
       "      <td>1 (2.4)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>IV</th>\n",
       "      <td>14 (0.3)</td>\n",
       "      <td>14 (0.3)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">airway, n (%)</th>\n",
       "      <th>Nasal</th>\n",
       "      <td>7 (0.1)</td>\n",
       "      <td>7 (0.1)</td>\n",
       "      <td></td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Chi-squared (warning: expected count &lt; 5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Oral</th>\n",
       "      <td>5959 (99.8)</td>\n",
       "      <td>5915 (99.8)</td>\n",
       "      <td>44 (95.7)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tracheostomy</th>\n",
       "      <td>7 (0.1)</td>\n",
       "      <td>5 (0.1)</td>\n",
       "      <td>2 (4.3)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tubesize, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>7.0 [7.0,7.5]</td>\n",
       "      <td>7.0 [7.0,7.5]</td>\n",
       "      <td>7.5 [7.0,7.5]</td>\n",
       "      <td>0.202</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"9\" valign=\"top\">dltubesize, n (%)</th>\n",
       "      <th>Left-24</th>\n",
       "      <td>3 (0.3)</td>\n",
       "      <td>3 (0.3)</td>\n",
       "      <td></td>\n",
       "      <td>0.706</td>\n",
       "      <td>Chi-squared (warning: expected count &lt; 5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Left-28</th>\n",
       "      <td>2 (0.2)</td>\n",
       "      <td>2 (0.2)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Left-32</th>\n",
       "      <td>165 (17.7)</td>\n",
       "      <td>164 (17.8)</td>\n",
       "      <td>1 (11.1)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Left-35</th>\n",
       "      <td>388 (41.7)</td>\n",
       "      <td>385 (41.8)</td>\n",
       "      <td>3 (33.3)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Left-37</th>\n",
       "      <td>335 (36.0)</td>\n",
       "      <td>331 (35.9)</td>\n",
       "      <td>4 (44.4)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Left-39</th>\n",
       "      <td>1 (0.1)</td>\n",
       "      <td>1 (0.1)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Right-24</th>\n",
       "      <td>1 (0.1)</td>\n",
       "      <td>1 (0.1)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Right-35</th>\n",
       "      <td>16 (1.7)</td>\n",
       "      <td>15 (1.6)</td>\n",
       "      <td>1 (11.1)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Right-37</th>\n",
       "      <td>19 (2.0)</td>\n",
       "      <td>19 (2.1)</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_ebl, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>150.0 [50.0,300.0]</td>\n",
       "      <td>150.0 [50.0,300.0]</td>\n",
       "      <td>250.0 [100.0,1000.0]</td>\n",
       "      <td>0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_uo, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>160.0 [90.0,300.0]</td>\n",
       "      <td>160.0 [90.0,300.0]</td>\n",
       "      <td>200.0 [55.0,300.0]</td>\n",
       "      <td>0.918</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_rbc, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_ffp, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_crystalloid, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>700.0 [350.0,1350.0]</td>\n",
       "      <td>700.0 [350.0,1350.0]</td>\n",
       "      <td>1050.0 [400.0,1850.0]</td>\n",
       "      <td>0.077</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_colloid, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.003</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_ppf, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,100.0]</td>\n",
       "      <td>0.0 [0.0,100.0]</td>\n",
       "      <td>0.0 [0.0,60.0]</td>\n",
       "      <td>0.168</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_mdz, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.006</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_ftn, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.692</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_rocu, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>70.0 [50.0,90.0]</td>\n",
       "      <td>70.0 [50.0,90.0]</td>\n",
       "      <td>70.0 [50.0,90.0]</td>\n",
       "      <td>0.627</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_vecu, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.742</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_eph, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>5.0 [0.0,10.0]</td>\n",
       "      <td>5.0 [0.0,10.0]</td>\n",
       "      <td>0.0 [0.0,5.0]</td>\n",
       "      <td>0.058</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_phe, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,30.0]</td>\n",
       "      <td>0.002</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_epi, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>intraop_ca, median [Q1,Q3]</th>\n",
       "      <th></th>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,0.0]</td>\n",
       "      <td>0.0 [0.0,300.0]</td>\n",
       "      <td>&lt;0.001</td>\n",
       "      <td>Kruskal-Wallis</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div><br />[1] Chi-squared tests for the following variables may be invalid due to the low number of observations: asa, department, optype, approach, position, ane_type, preop_ecg, preop_pft, cormack, airway, dltubesize.<br />"
      ],
      "text/plain": [
       "                                                                                                                             Grouped by death_inhosp                                                                                                \n",
       "                                                                                                                                             Overall                     0                      1 P-Value                                       Test\n",
       "n                                                                                                                                               6388                  6331                     57                                                   \n",
       "caseend, median [Q1,Q3]                                                                                                                2.8 [1.7,4.2]         2.8 [1.7,4.2]          2.7 [1.9,4.5]   0.376                             Kruskal-Wallis\n",
       "anestart, median [Q1,Q3]                                                                                                            -0.1 [-0.3,-0.1]      -0.1 [-0.3,-0.1]       -0.1 [-0.3,-0.1]   0.517                             Kruskal-Wallis\n",
       "aneend, median [Q1,Q3]                                                                                                                 2.7 [1.7,4.2]         2.7 [1.7,4.2]          2.7 [1.7,4.6]   0.232                             Kruskal-Wallis\n",
       "opstart, median [Q1,Q3]                                                                                                               0.4 [-0.1,0.7]        0.4 [-0.1,0.7]         0.4 [-0.1,0.7]   0.796                             Kruskal-Wallis\n",
       "opend, median [Q1,Q3]                                                                                                                  2.5 [1.5,4.0]         2.5 [1.5,4.0]          2.5 [1.6,4.4]   0.246                             Kruskal-Wallis\n",
       "adm, median [Q1,Q3]                                                                                                                 -2.3 [-2.6,-1.5]      -2.3 [-2.6,-1.5]      -2.8 [-16.8,-2.3]  <0.001                             Kruskal-Wallis\n",
       "dis, median [Q1,Q3]                                                                                                                    4.6 [2.4,7.5]         4.5 [2.4,7.5]        13.5 [5.0,30.4]  <0.001                             Kruskal-Wallis\n",
       "devices, median [Q1,Q3]                                                                                                                5.0 [4.0,5.0]         5.0 [4.0,5.0]          5.0 [4.0,5.0]   0.307                             Kruskal-Wallis\n",
       "tracks, median [Q1,Q3]                                                                                                              78.0 [73.0,83.0]      78.0 [74.0,83.0]       78.0 [72.0,83.0]   0.505                             Kruskal-Wallis\n",
       "casedur, median [Q1,Q3]                                                                                                                0.0 [0.0,0.1]         0.0 [0.0,0.1]          0.0 [0.0,0.1]   0.450                             Kruskal-Wallis\n",
       "age, median [Q1,Q3]                                                                                                                 59.0 [48.0,68.0]      59.0 [48.0,68.0]       61.0 [47.0,73.0]   0.452                             Kruskal-Wallis\n",
       "sex, n (%)                          F                                                                                                    3145 (49.2)           3125 (49.4)              20 (35.1)   0.044                                Chi-squared\n",
       "                                    M                                                                                                    3243 (50.8)           3206 (50.6)              37 (64.9)                                                   \n",
       "height, median [Q1,Q3]                                                                                                           162.2 [156.1,168.7]   162.1 [156.1,168.7]    165.4 [158.2,171.0]   0.392                             Kruskal-Wallis\n",
       "weight, median [Q1,Q3]                                                                                                              60.5 [53.3,68.7]      60.5 [53.4,68.7]       60.3 [51.3,71.2]   0.791                             Kruskal-Wallis\n",
       "bmi, median [Q1,Q3]                                                                                                                 23.1 [20.9,25.4]      23.1 [20.9,25.4]       22.7 [20.7,25.3]   0.737                             Kruskal-Wallis\n",
       "asa, n (%)                          1.0                                                                                                  1792 (28.6)           1783 (28.8)               9 (16.4)  <0.001  Chi-squared (warning: expected count < 5)\n",
       "                                    2.0                                                                                                  3699 (59.1)           3682 (59.4)              17 (30.9)                                                   \n",
       "                                    3.0                                                                                                   703 (11.2)            686 (11.1)              17 (30.9)                                                   \n",
       "                                    4.0                                                                                                     48 (0.8)              36 (0.6)              12 (21.8)                                                   \n",
       "                                    6.0                                                                                                     13 (0.2)              13 (0.2)                                                                          \n",
       "emop, n (%)                         0                                                                                                    5606 (87.8)           5578 (88.1)              28 (49.1)  <0.001                                Chi-squared\n",
       "                                    1                                                                                                     782 (12.2)            753 (11.9)              29 (50.9)                                                   \n",
       "department, n (%)                   General surgery                                                                                      4930 (77.2)           4886 (77.2)              44 (77.2)   1.000  Chi-squared (warning: expected count < 5)\n",
       "                                    Gynecology                                                                                             230 (3.6)             228 (3.6)                2 (3.5)                                                   \n",
       "                                    Thoracic surgery                                                                                     1111 (17.4)           1101 (17.4)              10 (17.5)                                                   \n",
       "                                    Urology                                                                                                117 (1.8)             116 (1.8)                1 (1.8)                                                   \n",
       "optype, n (%)                       Biliary/Pancreas                                                                                      812 (12.7)            809 (12.8)                3 (5.3)  <0.001  Chi-squared (warning: expected count < 5)\n",
       "                                    Breast                                                                                                 434 (6.8)             432 (6.8)                2 (3.5)                                                   \n",
       "                                    Colorectal                                                                                           1350 (21.1)           1341 (21.2)               9 (15.8)                                                   \n",
       "                                    Hepatic                                                                                                258 (4.0)             256 (4.0)                2 (3.5)                                                   \n",
       "                                    Major resection                                                                                        584 (9.1)             578 (9.1)               6 (10.5)                                                   \n",
       "                                    Minor resection                                                                                        553 (8.7)             553 (8.7)                                                                          \n",
       "                                    Others                                                                                                799 (12.5)            775 (12.2)              24 (42.1)                                                   \n",
       "                                    Stomach                                                                                               676 (10.6)            672 (10.6)                4 (7.0)                                                   \n",
       "                                    Thyroid                                                                                                257 (4.0)             257 (4.1)                                                                          \n",
       "                                    Transplantation                                                                                        403 (6.3)             399 (6.3)                4 (7.0)                                                   \n",
       "                                    Vascular                                                                                               262 (4.1)             259 (4.1)                3 (5.3)                                                   \n",
       "approach, n (%)                     Open                                                                                                 3365 (52.7)           3325 (52.5)              40 (70.2)   0.018  Chi-squared (warning: expected count < 5)\n",
       "                                    Robotic                                                                                                269 (4.2)             266 (4.2)                3 (5.3)                                                   \n",
       "                                    Videoscopic                                                                                          2754 (43.1)           2740 (43.3)              14 (24.6)                                                   \n",
       "position, n (%)                     Left kidney                                                                                              4 (0.1)               4 (0.1)                          0.594  Chi-squared (warning: expected count < 5)\n",
       "                                    Left lateral decubitus                                                                                 556 (9.0)             554 (9.0)                2 (3.6)                                                   \n",
       "                                    Lithotomy                                                                                             994 (16.0)            989 (16.1)                5 (8.9)                                                   \n",
       "                                    Prone                                                                                                  148 (2.4)             148 (2.4)                                                                          \n",
       "                                    Reverse Trendelenburg                                                                                   74 (1.2)              73 (1.2)                1 (1.8)                                                   \n",
       "                                    Right kidney                                                                                             2 (0.0)               2 (0.0)                                                                          \n",
       "                                    Right lateral decubitus                                                                                493 (8.0)             488 (8.0)                5 (8.9)                                                   \n",
       "                                    Sitting                                                                                                  5 (0.1)               5 (0.1)                                                                          \n",
       "                                    Supine                                                                                               3883 (62.7)           3840 (62.6)              43 (76.8)                                                   \n",
       "                                    Trendelenburg                                                                                           35 (0.6)              35 (0.6)                                                                          \n",
       "ane_type, n (%)                     General                                                                                              6043 (94.6)           5987 (94.6)              56 (98.2)   0.453  Chi-squared (warning: expected count < 5)\n",
       "                                    Sedationalgesia                                                                                         72 (1.1)              72 (1.1)                                                                          \n",
       "                                    Spinal                                                                                                 273 (4.3)             272 (4.3)                1 (1.8)                                                   \n",
       "opdur, median [Q1,Q3]                                                                                                                  0.0 [0.0,0.1]         0.0 [0.0,0.1]          0.0 [0.0,0.1]   0.417                             Kruskal-Wallis\n",
       "anedur, median [Q1,Q3]                                                                                                                 0.0 [0.0,0.1]         0.0 [0.0,0.1]          0.0 [0.0,0.1]   0.336                             Kruskal-Wallis\n",
       "los_postop, median [Q1,Q3]                                                                                                             5.0 [3.0,8.0]         5.0 [3.0,8.0]        14.0 [6.0,32.0]  <0.001                             Kruskal-Wallis\n",
       "los_icu, median [Q1,Q3]                                                                                                                0.0 [0.0,0.0]         0.0 [0.0,0.0]         1.0 [0.0,16.0]  <0.001                             Kruskal-Wallis\n",
       "death_inhosp, n (%)                 0                                                                                                    6331 (99.1)          6331 (100.0)                         <0.001                             Fisher's exact\n",
       "                                    1                                                                                                       57 (0.9)                                   57 (100.0)                                                   \n",
       "preop_htn, n (%)                    0                                                                                                    4423 (69.2)           4385 (69.3)              38 (66.7)   0.781                                Chi-squared\n",
       "                                    1                                                                                                    1965 (30.8)           1946 (30.7)              19 (33.3)                                                   \n",
       "preop_dm, n (%)                     0                                                                                                    5727 (89.7)           5673 (89.6)              54 (94.7)   0.295                                Chi-squared\n",
       "                                    1                                                                                                     661 (10.3)            658 (10.4)                3 (5.3)                                                   \n",
       "preop_ecg, n (%)                    1st degree A-V block                                                                                    12 (0.2)              11 (0.2)                1 (1.8)  <0.001  Chi-squared (warning: expected count < 5)\n",
       "                                    1st degree A-V block with Premature atrial complexes                                                     1 (0.0)               1 (0.0)                                                                          \n",
       "                                    1st degree A-V block with Premature supraventricular complexes, Left bundle branch block                 1 (0.0)               1 (0.0)                                                                          \n",
       "                                    1st degree A-V block, Left bundle branch block                                                           1 (0.0)               1 (0.0)                                                                          \n",
       "                                    AV sequential or dual chamber electronic pacemaker                                                       1 (0.0)               1 (0.0)                                                                          \n",
       "                                    Atrial fibrillation                                                                                      8 (0.1)               7 (0.1)                1 (1.8)                                                   \n",
       "                                    Atrial fibrillation with premature ventricular or aberrantly conducted complexes                         2 (0.0)               2 (0.0)                                                                          \n",
       "                                    Atrial fibrillation with premature ventricular, Incomplete left bundle block                             1 (0.0)               1 (0.0)                                                                          \n",
       "                                    Atrial fibrillation with rapid ventricular response                                                      2 (0.0)               2 (0.0)                                                                          \n",
       "                                    Atrial fibrillation with slow ventricular response                                                       2 (0.0)               2 (0.0)                                                                          \n",
       "                                    Atrial fibrillation, Right bundle branch block                                                           1 (0.0)               1 (0.0)                                                                          \n",
       "                                    Atrial flutter with 2:1 A-V conduction                                                                   1 (0.0)               1 (0.0)                                                                          \n",
       "                                    Atrial flutter with variable A-V block                                                                   1 (0.0)               1 (0.0)                                                                          \n",
       "                                    Complete right bundle branch block, occasional premature supraventricular complexes                      1 (0.0)                                      1 (1.8)                                                   \n",
       "                                    Electronic ventricular pacemaker                                                                         1 (0.0)               1 (0.0)                                                                          \n",
       "                                    Incomplete right bundle branch block                                                                     9 (0.1)               8 (0.1)                1 (1.8)                                                   \n",
       "                                    Incomplete right bundle branch block, Left anterior fascicular block                                     1 (0.0)               1 (0.0)                                                                          \n",
       "                                    Left anterior fascicular block                                                                           3 (0.0)               3 (0.0)                                                                          \n",
       "                                    Left anterior hemiblock                                                                                  1 (0.0)               1 (0.0)                                                                          \n",
       "                                    Left posterior fascicular block                                                                          1 (0.0)               1 (0.0)                                                                          \n",
       "                                    Normal Sinus Rhythm                                                                                  6306 (98.7)           6258 (98.8)              48 (84.2)                                                   \n",
       "                                    Premature atrial complexes                                                                               7 (0.1)               6 (0.1)                1 (1.8)                                                   \n",
       "                                    Premature supraventricular and ventricular complexes, Right bundle branch block                          1 (0.0)               1 (0.0)                                                                          \n",
       "                                    Premature supraventricular complexes                                                                     2 (0.0)               2 (0.0)                                                                          \n",
       "                                    Premature ventricular complexes                                                                         10 (0.2)               9 (0.1)                1 (1.8)                                                   \n",
       "                                    Right bundle branch block                                                                               10 (0.2)               7 (0.1)                3 (5.3)                                                   \n",
       "                                    Right bundle branch block, Left anterior fascicular block                                                1 (0.0)               1 (0.0)                                                                          \n",
       "preop_pft, n (%)                    Borderline obstructive                                                                                   8 (0.1)               8 (0.1)                         <0.001  Chi-squared (warning: expected count < 5)\n",
       "                                    Mild obstructive                                                                                       488 (7.6)             484 (7.6)                4 (7.0)                                                   \n",
       "                                    Mild restrictive                                                                                       261 (4.1)             255 (4.0)               6 (10.5)                                                   \n",
       "                                    Mixed or pure obstructive                                                                              100 (1.6)             100 (1.6)                                                                          \n",
       "                                    Moderate obstructive                                                                                   114 (1.8)             114 (1.8)                                                                          \n",
       "                                    Moderate restrictive                                                                                    29 (0.5)              29 (0.5)                                                                          \n",
       "                                    Normal                                                                                               5348 (83.7)           5304 (83.8)              44 (77.2)                                                   \n",
       "                                    Severe obstructive                                                                                       4 (0.1)               4 (0.1)                                                                          \n",
       "                                    Severe restrictive                                                                                      36 (0.6)              33 (0.5)                3 (5.3)                                                   \n",
       "preop_hb, median [Q1,Q3]                                                                                                            13.0 [11.6,14.2]      13.0 [11.6,14.2]        11.2 [9.1,13.0]  <0.001                             Kruskal-Wallis\n",
       "preop_plt, median [Q1,Q3]                                                                                                        235.0 [191.0,283.0]   235.0 [191.0,283.0]    198.0 [105.0,270.0]   0.004                             Kruskal-Wallis\n",
       "preop_pt, median [Q1,Q3]                                                                                                          101.0 [94.0,109.0]    101.0 [94.0,110.0]      86.0 [53.0,100.0]  <0.001                             Kruskal-Wallis\n",
       "preop_aptt, median [Q1,Q3]                                                                                                          32.1 [30.1,34.4]      32.1 [30.0,34.4]       34.1 [30.9,53.0]   0.001                             Kruskal-Wallis\n",
       "preop_na, median [Q1,Q3]                                                                                                         140.0 [139.0,142.0]   140.0 [139.0,142.0]    138.0 [134.0,140.0]  <0.001                             Kruskal-Wallis\n",
       "preop_k, median [Q1,Q3]                                                                                                                4.2 [3.9,4.4]         4.2 [3.9,4.4]          3.9 [3.8,4.2]  <0.001                             Kruskal-Wallis\n",
       "preop_gluc, median [Q1,Q3]                                                                                                        103.0 [94.0,122.0]    103.0 [94.0,122.0]     111.0 [95.0,136.0]   0.150                             Kruskal-Wallis\n",
       "preop_alb, median [Q1,Q3]                                                                                                              4.2 [3.8,4.4]         4.2 [3.8,4.4]          3.0 [2.7,4.1]  <0.001                             Kruskal-Wallis\n",
       "preop_ast, median [Q1,Q3]                                                                                                           20.0 [17.0,26.0]      20.0 [17.0,26.0]       27.0 [19.0,83.5]  <0.001                             Kruskal-Wallis\n",
       "preop_alt, median [Q1,Q3]                                                                                                           18.0 [13.0,27.0]      18.0 [13.0,27.0]       26.5 [16.2,94.0]  <0.001                             Kruskal-Wallis\n",
       "preop_bun, median [Q1,Q3]                                                                                                           14.0 [11.0,17.0]      14.0 [11.0,17.0]       15.0 [12.0,19.0]   0.111                             Kruskal-Wallis\n",
       "preop_cr, median [Q1,Q3]                                                                                                               0.8 [0.7,0.9]         0.8 [0.7,0.9]          0.7 [0.5,1.0]   0.073                             Kruskal-Wallis\n",
       "preop_ph, median [Q1,Q3]                                                                                                               7.4 [7.4,7.4]         7.4 [7.4,7.4]          7.4 [7.4,7.5]   0.170                             Kruskal-Wallis\n",
       "preop_hco3, median [Q1,Q3]                                                                                                          24.3 [22.7,26.0]      24.3 [22.7,26.0]       24.0 [23.2,24.9]   0.773                             Kruskal-Wallis\n",
       "preop_be, median [Q1,Q3]                                                                                                             -0.1 [-1.9,1.7]       -0.1 [-1.9,1.7]        -0.1 [-1.5,1.2]   0.958                             Kruskal-Wallis\n",
       "preop_pao2, median [Q1,Q3]                                                                                                         96.0 [78.2,120.8]     96.0 [78.2,120.8]      95.9 [73.1,114.7]   0.854                             Kruskal-Wallis\n",
       "preop_paco2, median [Q1,Q3]                                                                                                         39.5 [36.0,43.7]      39.5 [36.0,43.8]       36.5 [35.4,37.8]   0.189                             Kruskal-Wallis\n",
       "preop_sao2, median [Q1,Q3]                                                                                                          97.0 [94.8,98.2]      97.0 [94.8,98.1]       97.6 [92.6,98.6]   0.620                             Kruskal-Wallis\n",
       "cormack, n (%)                      I                                                                                                    5178 (93.2)           5140 (93.3)              38 (92.7)   0.563  Chi-squared (warning: expected count < 5)\n",
       "                                    II                                                                                                     235 (4.2)             233 (4.2)                2 (4.9)                                                   \n",
       "                                    IIIa                                                                                                    91 (1.6)              91 (1.7)                                                                          \n",
       "                                    IIIb                                                                                                    35 (0.6)              34 (0.6)                1 (2.4)                                                   \n",
       "                                    IV                                                                                                      14 (0.3)              14 (0.3)                                                                          \n",
       "airway, n (%)                       Nasal                                                                                                    7 (0.1)               7 (0.1)                         <0.001  Chi-squared (warning: expected count < 5)\n",
       "                                    Oral                                                                                                 5959 (99.8)           5915 (99.8)              44 (95.7)                                                   \n",
       "                                    Tracheostomy                                                                                             7 (0.1)               5 (0.1)                2 (4.3)                                                   \n",
       "tubesize, median [Q1,Q3]                                                                                                               7.0 [7.0,7.5]         7.0 [7.0,7.5]          7.5 [7.0,7.5]   0.202                             Kruskal-Wallis\n",
       "dltubesize, n (%)                   Left-24                                                                                                  3 (0.3)               3 (0.3)                          0.706  Chi-squared (warning: expected count < 5)\n",
       "                                    Left-28                                                                                                  2 (0.2)               2 (0.2)                                                                          \n",
       "                                    Left-32                                                                                               165 (17.7)            164 (17.8)               1 (11.1)                                                   \n",
       "                                    Left-35                                                                                               388 (41.7)            385 (41.8)               3 (33.3)                                                   \n",
       "                                    Left-37                                                                                               335 (36.0)            331 (35.9)               4 (44.4)                                                   \n",
       "                                    Left-39                                                                                                  1 (0.1)               1 (0.1)                                                                          \n",
       "                                    Right-24                                                                                                 1 (0.1)               1 (0.1)                                                                          \n",
       "                                    Right-35                                                                                                16 (1.7)              15 (1.6)               1 (11.1)                                                   \n",
       "                                    Right-37                                                                                                19 (2.0)              19 (2.1)                                                                          \n",
       "intraop_ebl, median [Q1,Q3]                                                                                                       150.0 [50.0,300.0]    150.0 [50.0,300.0]   250.0 [100.0,1000.0]   0.001                             Kruskal-Wallis\n",
       "intraop_uo, median [Q1,Q3]                                                                                                        160.0 [90.0,300.0]    160.0 [90.0,300.0]     200.0 [55.0,300.0]   0.918                             Kruskal-Wallis\n",
       "intraop_rbc, median [Q1,Q3]                                                                                                            0.0 [0.0,0.0]         0.0 [0.0,0.0]          0.0 [0.0,0.0]  <0.001                             Kruskal-Wallis\n",
       "intraop_ffp, median [Q1,Q3]                                                                                                            0.0 [0.0,0.0]         0.0 [0.0,0.0]          0.0 [0.0,0.0]  <0.001                             Kruskal-Wallis\n",
       "intraop_crystalloid, median [Q1,Q3]                                                                                             700.0 [350.0,1350.0]  700.0 [350.0,1350.0]  1050.0 [400.0,1850.0]   0.077                             Kruskal-Wallis\n",
       "intraop_colloid, median [Q1,Q3]                                                                                                        0.0 [0.0,0.0]         0.0 [0.0,0.0]          0.0 [0.0,0.0]   0.003                             Kruskal-Wallis\n",
       "intraop_ppf, median [Q1,Q3]                                                                                                          0.0 [0.0,100.0]       0.0 [0.0,100.0]         0.0 [0.0,60.0]   0.168                             Kruskal-Wallis\n",
       "intraop_mdz, median [Q1,Q3]                                                                                                            0.0 [0.0,0.0]         0.0 [0.0,0.0]          0.0 [0.0,0.0]   0.006                             Kruskal-Wallis\n",
       "intraop_ftn, median [Q1,Q3]                                                                                                            0.0 [0.0,0.0]         0.0 [0.0,0.0]          0.0 [0.0,0.0]   0.692                             Kruskal-Wallis\n",
       "intraop_rocu, median [Q1,Q3]                                                                                                        70.0 [50.0,90.0]      70.0 [50.0,90.0]       70.0 [50.0,90.0]   0.627                             Kruskal-Wallis\n",
       "intraop_vecu, median [Q1,Q3]                                                                                                           0.0 [0.0,0.0]         0.0 [0.0,0.0]          0.0 [0.0,0.0]   0.742                             Kruskal-Wallis\n",
       "intraop_eph, median [Q1,Q3]                                                                                                           5.0 [0.0,10.0]        5.0 [0.0,10.0]          0.0 [0.0,5.0]   0.058                             Kruskal-Wallis\n",
       "intraop_phe, median [Q1,Q3]                                                                                                            0.0 [0.0,0.0]         0.0 [0.0,0.0]         0.0 [0.0,30.0]   0.002                             Kruskal-Wallis\n",
       "intraop_epi, median [Q1,Q3]                                                                                                            0.0 [0.0,0.0]         0.0 [0.0,0.0]          0.0 [0.0,0.0]  <0.001                             Kruskal-Wallis\n",
       "intraop_ca, median [Q1,Q3]                                                                                                             0.0 [0.0,0.0]         0.0 [0.0,0.0]        0.0 [0.0,300.0]  <0.001                             Kruskal-Wallis\n",
       "[1] Chi-squared tests for the following variables may be invalid due to the low number of observations: asa, department, optype, approach, position, ane_type, preop_ecg, preop_pft, cormack, airway, dltubesize."
      ]
     },
     "execution_count": 5,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import scipy.stats as stat\n",
    "from tableone import TableOne\n",
    "import pandas as pd\n",
    "\n",
    "# Load a dataset\n",
    "df = pd.read_csv('https://api.vitaldb.net/cases')\n",
    "\n",
    "# Exclude variables that will not be used in statistics\n",
    "df.drop(columns=['caseid', 'subjectid', 'dx', 'opname', 'casestart', 'iv1', 'iv2', 'aline1', 'aline2', 'cline1', 'cline2', 'lmasize'], inplace=True)\n",
    "\n",
    "# Change the following five variables by time and date units\n",
    "df.loc[:, ['caseend', 'anestart', 'aneend', 'opstart', 'opend']] /= 3600\n",
    "df.loc[:, ['adm', 'dis']] /= 3600 * 24\n",
    "\n",
    "# Set categorical variables\n",
    "categoricals = [col for col in df.columns if df[col].dtype == 'object' or df[col].dtype == 'str' or len(df[col].unique()) < 7]\n",
    "\n",
    "# Store variables from nonnormal distribution in a new list called 'nonnormals'\n",
    "nonnormals = [col for col in df.columns if col not in categoricals and stat.normaltest(df[col], nan_policy='omit')[1] < 0.05]\n",
    "\n",
    "# Create a group table\n",
    "tbl = TableOne(df, columns=list(df.columns), categorical=categoricals, nonnormal=nonnormals, groupby='death_inhosp', missing=False, pval=True, htest_name=True)\n",
    "pd.set_option('display.max_rows', 500)\n",
    "tbl"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "authorship_tag": "ABX9TyOLo1UToO9UmQUurXnHD3Ii",
   "include_colab_link": true,
   "name": "vitaldb_tableone.ipynb",
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
